package com.aosan.website.auth.handler

import com.aosan.website.common.core.utils.BaseExceptionHandler
import com.aosan.website.common.core.utils.ResultData
import org.springframework.security.core.userdetails.UsernameNotFoundException
import org.springframework.security.oauth2.common.exceptions.InvalidGrantException
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler

@ControllerAdvice
class ExceptionHandler:BaseExceptionHandler() {

    @ExceptionHandler(UsernameNotFoundException::class)
    fun userNotFoundException():Any{
        return ResultData.err("","用户不存在")
    }

    @ExceptionHandler(InvalidGrantException::class)
    fun tokenException():Any{
        return ResultData.err("","Token Error")
    }
}